home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / beans / XMLDecoder.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.5 KB  |  109 lines

  1. package java.beans;
  2.  
  3. import com.sun.beans.ObjectHandler;
  4. import java.io.IOException;
  5. import java.io.InputStream;
  6. import java.lang.ref.Reference;
  7. import java.lang.ref.WeakReference;
  8. import javax.xml.parsers.ParserConfigurationException;
  9. import javax.xml.parsers.SAXParser;
  10. import javax.xml.parsers.SAXParserFactory;
  11. import org.xml.sax.SAXException;
  12.  
  13. public class XMLDecoder {
  14.    // $FF: renamed from: in java.io.InputStream
  15.    private InputStream field_0;
  16.    private Object owner;
  17.    private ExceptionListener exceptionListener;
  18.    private ObjectHandler handler;
  19.    private Reference clref;
  20.  
  21.    public XMLDecoder(InputStream var1) {
  22.       this(var1, (Object)null);
  23.    }
  24.  
  25.    public XMLDecoder(InputStream var1, Object var2) {
  26.       this(var1, var2, (ExceptionListener)null);
  27.    }
  28.  
  29.    public XMLDecoder(InputStream var1, Object var2, ExceptionListener var3) {
  30.       this(var1, var2, var3, (ClassLoader)null);
  31.    }
  32.  
  33.    public XMLDecoder(InputStream var1, Object var2, ExceptionListener var3, ClassLoader var4) {
  34.       this.field_0 = var1;
  35.       this.setOwner(var2);
  36.       this.setExceptionListener(var3);
  37.       this.setClassLoader(var4);
  38.    }
  39.  
  40.    private void setClassLoader(ClassLoader var1) {
  41.       if (var1 != null) {
  42.          this.clref = new WeakReference(var1);
  43.       }
  44.  
  45.    }
  46.  
  47.    private ClassLoader getClassLoader() {
  48.       return this.clref != null ? (ClassLoader)this.clref.get() : null;
  49.    }
  50.  
  51.    public void close() {
  52.       if (this.field_0 != null) {
  53.          this.getHandler();
  54.  
  55.          try {
  56.             this.field_0.close();
  57.          } catch (IOException var2) {
  58.             this.getExceptionListener().exceptionThrown(var2);
  59.          }
  60.       }
  61.  
  62.    }
  63.  
  64.    public void setExceptionListener(ExceptionListener var1) {
  65.       this.exceptionListener = var1;
  66.    }
  67.  
  68.    public ExceptionListener getExceptionListener() {
  69.       return this.exceptionListener != null ? this.exceptionListener : Statement.defaultExceptionListener;
  70.    }
  71.  
  72.    public Object readObject() {
  73.       return this.field_0 == null ? null : this.getHandler().dequeueResult();
  74.    }
  75.  
  76.    public void setOwner(Object var1) {
  77.       this.owner = var1;
  78.    }
  79.  
  80.    public Object getOwner() {
  81.       return this.owner;
  82.    }
  83.  
  84.    private ObjectHandler getHandler() {
  85.       if (this.handler == null) {
  86.          SAXParserFactory var1 = SAXParserFactory.newInstance();
  87.  
  88.          try {
  89.             SAXParser var2 = var1.newSAXParser();
  90.             this.handler = new ObjectHandler(this, this.getClassLoader());
  91.             var2.parse(this.field_0, this.handler);
  92.          } catch (ParserConfigurationException var4) {
  93.             this.getExceptionListener().exceptionThrown(var4);
  94.          } catch (SAXException var5) {
  95.             Object var3 = var5.getException();
  96.             if (var3 == null) {
  97.                var3 = var5;
  98.             }
  99.  
  100.             this.getExceptionListener().exceptionThrown((Exception)var3);
  101.          } catch (IOException var6) {
  102.             this.getExceptionListener().exceptionThrown(var6);
  103.          }
  104.       }
  105.  
  106.       return this.handler;
  107.    }
  108. }
  109.